<?php
class Product_model extends CI_Model
{
    private $ci;
    public function __construct(){
        $this->load->database();
        $this->ci = & get_instance();
    }

    public function addProduct($data){
    	$rs = $this->db->insert("product",$data);
        if($rs){
            return $this->db->insert_id();
        }else{
            return false;
        }
    }

    public function getProduct($data,$limit='all',$orderby=''){
        $this->db->select()->from("product")->where($data);
        if($limit!='all'){
             $limit = abs($limit);
             $this->db->limit($limit);
        }
        if($orderby!=''){
            $this->db->order_by($orderby);
        }
        $query =  $this->db->get();
        if($limit==1) return $query->row_array();
        return $query->result_array();
    }

}